package com.icez.designmode

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.icez.iosdatescroll.IosDateScrollAdapter
import com.icez.iosdatescroll.IosDateScrollView

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val idsv = findViewById<IosDateScrollView>(R.id.idsv)
        val list = ArrayList<String>()
        for (i in 0..20) {
            list.add("数据" + i)
        }

        idsv.setIosDateScrollViewAdapter(object :
            IosDateScrollAdapter<String>(this, R.layout.ios_date_item, list) {
            
            override fun onBusinessOperation(
                holder: ViewHolder,
                data:String?,
                position: Int,
                isSelected: Boolean
            ) {
                Log.e("icez","isSelected: "+isSelected+" position: "+position)
                val item_tv = holder.getView<TextView>(R.id.item_tv)
                if(isSelected){
                    item_tv?.text = "已经选择"+data
                }else{
                    item_tv?.text = "没选中"+data
                }
                holder.mItemView.setOnClickListener {
                    Log.e("icez","点击"+position)
                    idsv.setScrollPosition(4)
//                    resetInit(idsv,position)
                }
            }


        })

        idsv.setScrollPosition(13)
    }
}